package com.yupi.longojbackenduserservice.controller.inner;

import com.yupi.longojbackendmodel.entity.User;
import com.yupi.longojbackendserviceclient.service.UserFeignClient;
import com.yupi.longojbackenduserservice.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;
import java.util.List;

/**
 * 该服务仅用于内部调用，不提供给前端
 */
@RestController
@RequestMapping("/inner")
public class UserInnerController implements UserFeignClient {
    @Autowired
    private UserService userService;
    /**
     * 根据id获取用户
     * @param userId
     * @return
     */
    @Override
    @GetMapping("/get/id")
  public   User getById(@RequestParam("userId") Long userId){
        User user = userService.getById(userId);
        return user;
    }


    /**
     * 根据id列表获取用户列表
     * @param idList
     * @return
     */
    @Override
    @GetMapping("/get/ids")
   public List<User> listByIds(@RequestParam("idList") Collection<Long> idList){
        return userService.listByIds(idList);
    }


}
